package com.rbtnet.ssc;

import com.rbtnet.ssc.banker.Banker;
import com.rbtnet.ssc.banker.provider.B365Provider;
import com.rbtnet.ssc.ticket.Ticket;
import com.rbtnet.ssc.ticket.strategy.RandomTicketStrategy;
import java.util.Scanner;

/**
 * 
 * @author 1136009436@qq.com
 *
 */
public class Client {
	
    public static void main(String[] args) {
        Banker banker = new B365Provider();
        Ticket ticket = new RandomTicketStrategy();

    	Scanner in = new Scanner(System.in);
    	System.out.println("用户名：");
        String username = in.nextLine();
        System.out.println("密码：");
        String password = in.nextLine();

        banker.login(username, password);

        Double balance = 0.0;
        while(true){
            // 如果大数据分析
            String bill = "12345";
            if(balance < banker.balance()){
            	bill = banker.getFfc();  // 大数据分析
            	if(bill == null){
            		bill = ticket.produce();
            	}
            }else{
            	bill = ticket.produce(); // 机选
            }
            
            String lottyid = banker.getCountdown();
            String adv = banker.getAdv();
            
            String data = "[\"37|1|112345|1|110|5|10|,,,,"+bill+"\"]"; // 5角
            //String data = "[\"37|1|112345|1|110|5|100|,,,,"+ffc+"\"]";  5分
            banker.doBet(lottyid, data, adv);
            
            balance = banker.balance();
            System.out.println("余额："+balance);
            try {
				Thread.sleep(1000*60);
			} catch (Exception e) {
				e.printStackTrace();
			}
        }
    }  

}
